<?php
/**
 * Created by PhpStorm.
 * User: bg
 * Date: 2017/8/26 0026
 * Time: 上午 11:04
 */
namespace app\common\model;

use think\Model;
use think\Db;
use think\Loader;
/*
 * 站内信内容
 */
class StationContent extends Model{
    protected $admin_db_user_name = 'admin_user';
    protected $admin_db_user_group_name = 'admin_auth_group';
    protected $administrative_db_user_name = 'administrative_user';
    protected $administrative_db_user_group_name = 'administrative_auth_group';
    protected $operation_db_user_name = 'operation_user';
    protected $operation_db_user_group_name = 'operation_auth_group';
    //添加内容
    public function add($data){
        $ret = $this->insertGetId($data);
        return $ret;
    }
    //删除内容
    public function del($message_id)
    {
        $map['message_id'] = $message_id;
        $ret = $this->where($map)->delete();
        return $ret;
    }
    //修改内容
    public function mod($message_id,$data){
        $map['message_id'] = $message_id;
        $ret = $this->where($map)->update($data);
        return $ret;
    }

    //根据ID查寻内容
    public function search($message_id){
        $map['message_id'] = $message_id;
        $ret = $this->where($map)->find();
        return $ret;
    }
    //获取各平台帐号
    public function getUsers(){
        $userDao = new User();
        $data = array();
        //总后台
        $adminUserList = $userDao->getInfoAll('*','1=1',$this->admin_db_user_name,$this->admin_db_user_group_name,'a.id desc');
        $data['admin'] = $adminUserList;
        //区域合伙人
        $operationUserList = $userDao->getOperationUserInfoAll('a.*,b.title,c.company_name','1=1',$this->operation_db_user_name,$this->operation_db_user_group_name,'c.company_name desc');
        $data['operation'] = $operationUserList;
        //行政中心
        $administrativeUserList = $userDao->getAdminUserInfoAll('a.*,b.title,c.company_name','1=1',$this->administrative_db_user_name,$this->administrative_db_user_group_name,'c.company_name desc');
        $data['administrative'] = $administrativeUserList;
        return $data;
    }


}
